
# 想通过某种对齐方式来格式化字符串
def demo_1():
    text = 'hello kepler'
    print(text.ljust(20))
    print(text.rjust(20))
    print(text.center(20))
    print(text.ljust(20, '='))
    print(text.rjust(20, '+'))
    print(text.center(20, '*'))

def demo_2():
    # 使用format函数进行对齐,推荐使用
    text = 'hello kepler'
    print(format(text, '>20'))
    print(format(text, '<20'))
    print(format(text, '^20'))
    print(format(text, '=>20s'))
    print(format(text, '*^20s'))
    print(format(text, '+<20s'))
    print('{:>10s} {:>20s}'.format('hello', 'kepler'))


if __name__ == '__main__':
    # demo_1()
    demo_2()